﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:c="clr-namespace:HomeUX.Controls;assembly=HomeUX.ClientLibrary"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Class="HomeUX.MusicClientLibrary.MusicQueueScreen"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    Width="800" Height="530" IsTabStop="False" mc:Ignorable="d" IsEnabled="False">

    <Grid x:Name="LayoutRoot" Background="{StaticResource DefaultBackgroundBrush}">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="ModeStates">
                <VisualState x:Name="NormalMode" />
                <VisualState x:Name="GoToAlbumMode">
                    <Storyboard>
                        <!-- Buttons -->
                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="GoToAlbumModeButton" Storyboard.TargetProperty="IsLit">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <sys:Boolean>true</sys:Boolean>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ReorderTracksModeButton" Storyboard.TargetProperty="IsLit">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <sys:Boolean>false</sys:Boolean>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="DeleteTracksModeButton" Storyboard.TargetProperty="IsLit">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <sys:Boolean>false</sys:Boolean>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <!-- GoToAlbumGroup -->
                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="GoToAlbumGroup" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible" />
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Duration="0:0:0.5" Storyboard.TargetName="GoToAlbumGroup" Storyboard.TargetProperty="Opacity" To="1" />
                        <!-- ReorderTracksGroup -->
                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ReorderTracksGroup" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Duration="0" Storyboard.TargetName="ReorderTracksGroup" Storyboard.TargetProperty="Opacity" To="0" />
                        <!-- DeleteTracksGroup -->
                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="DeleteTracksGroup" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Duration="0" Storyboard.TargetName="DeleteTracksGroup" Storyboard.TargetProperty="Opacity" To="0" />
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="ReorderTracksMode">
                    <Storyboard>
                        <!-- Buttons -->
                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="GoToAlbumModeButton" Storyboard.TargetProperty="IsLit">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <sys:Boolean>false</sys:Boolean>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ReorderTracksModeButton" Storyboard.TargetProperty="IsLit">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <sys:Boolean>true</sys:Boolean>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="DeleteTracksModeButton" Storyboard.TargetProperty="IsLit">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <sys:Boolean>false</sys:Boolean>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <!-- GoToAlbumGroup -->
                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="GoToAlbumGroup" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Duration="0" Storyboard.TargetName="GoToAlbumGroup" Storyboard.TargetProperty="Opacity" To="0" />
                        <!-- ReorderTracksGroup -->
                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ReorderTracksGroup" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible" />
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Duration="0:0:0.5" Storyboard.TargetName="ReorderTracksGroup" Storyboard.TargetProperty="Opacity" To="1" />
                        <!-- DeleteTracksGroup -->
                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="DeleteTracksGroup" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Duration="0" Storyboard.TargetName="DeleteTracksGroup" Storyboard.TargetProperty="Opacity" To="0" />
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="DeleteTracksMode">
                    <Storyboard>
                        <!-- Buttons -->
                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="GoToAlbumModeButton" Storyboard.TargetProperty="IsLit">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <sys:Boolean>false</sys:Boolean>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ReorderTracksModeButton" Storyboard.TargetProperty="IsLit">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <sys:Boolean>false</sys:Boolean>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="DeleteTracksModeButton" Storyboard.TargetProperty="IsLit">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <sys:Boolean>true</sys:Boolean>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <!-- GoToAlbumGroup -->
                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="GoToAlbumGroup" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Duration="0" Storyboard.TargetName="GoToAlbumGroup" Storyboard.TargetProperty="Opacity" To="0" />
                        <!-- ReorderTracksGroup -->
                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ReorderTracksGroup" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Duration="0" Storyboard.TargetName="ReorderTracksGroup" Storyboard.TargetProperty="Opacity" To="0" />
                        <!-- DeleteTracksGroup -->
                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="DeleteTracksGroup" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible" />
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Duration="0:0:0.5" Storyboard.TargetName="DeleteTracksGroup" Storyboard.TargetProperty="Opacity" To="1" />
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <Grid.Resources>
			<Style x:Key="TrackButtonStyle" TargetType="c:TouchButton">
				<Setter Property="Width" Value="285" />
				<Setter Property="HorizontalContentAlignment" Value="Left" />
			</Style>
            <Style x:Key="TrackButtonGridStyle" TargetType="Grid">
                <Setter Property="Width" Value="265" />
				<Setter Property="Height" Value="44" />
            </Style>
            <Style x:Key="TrackButtonTextStyle" TargetType="TextBlock">
				<Setter Property="HorizontalAlignment" Value="Left" />
				<Setter Property="VerticalAlignment" Value="Center" />
                <Setter Property="LineHeight" Value="16" />
                <Setter Property="LineStackingStrategy" Value="BlockLineHeight" />
                <Setter Property="TextWrapping" Value="Wrap" />
                <Setter Property="Margin" Value="8,0,8,0" />
            </Style>
            <Style x:Key="TrackButtonSequenceBorderStyle" TargetType="Border">
				<Setter Property="HorizontalAlignment" Value="Left" />
				<Setter Property="VerticalAlignment" Value="Top" />
                <Setter Property="BorderThickness" Value="1" />
                <Setter Property="BorderBrush" Value="Black" />
				<Setter Property="Background" Value="Yellow" />
            </Style>
            <Style x:Key="TrackButtonSequenceTextStyle" TargetType="TextBlock">
                <Setter Property="FontSize" Value="13" />
                <Setter Property="Margin" Value="4,0,4,0" />
            </Style>
		</Grid.Resources>

		<TextBlock x:Name="HeaderTextBlock" Text="{}Queue - {0} - Track {1} of {2} - {3}" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="18" Margin="10,10,0,0" />

        <c:TouchListBox x:Name="TracksListBox" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,54,12,0" Height="470"
            DragZoneVisibility="Hidden" ScrollButtonVisibility="VisibleAlways" ScrollSliderVisibility="VisibleAlways" IsEnabled="True" SelectionMode="None"
            ItemClick="TracksListBox_ItemClick" ListMargin="0,0,0,0" ViewportMinWidth="285" ItemAction="SetStringValue" ItemButtonStyle="{StaticResource TrackButtonStyle}"
            LayoutComplete="TracksListBox_LayoutComplete">
        </c:TouchListBox>

		<c:TouchButton x:Name="LoadPlaylistButton" Text="Load Queue from Playlist..." Width="120" HorizontalAlignment="Left" Margin="12,55,0,0" VerticalAlignment="Top" d:LayoutOverrides="Width, Height" Click="LoadPlaylistButton_Click" />
		<c:TouchButton x:Name="SaveQueueButton" Text="Save Queue to Playlist..." Width="120" HorizontalAlignment="Left" Margin="132,55,0,0" VerticalAlignment="Top" d:LayoutOverrides="Width, Height" Click="SaveQueueButton_Click" />
		<c:TouchButton x:Name="ForgetPlaylistButton" Text="Forget Playlist" Width="60" HorizontalAlignment="Left" Margin="252,55,0,0" VerticalAlignment="Top" d:LayoutOverrides="Width, Height" Click="ForgetPlaylistButton_Click" />

        <Grid Margin="12,107,0,0" HorizontalAlignment="Left" VerticalAlignment="Top">
			<TextBlock x:Name="QueueNewNotEmptyTextBlock" Visibility="Collapsed" FontSize="13" Foreground="Red">Queue has not been saved to a playlist</TextBlock>
			<TextBlock x:Name="QueueLoadedTextBlock" Visibility="Collapsed" FontSize="13">Queue was loaded from playlist:</TextBlock>
			<TextBlock x:Name="QueueLoadedModifiedTextBlock" Visibility="Collapsed" FontSize="13" Foreground="Red">Queue changed since it was loaded from playlist:</TextBlock>
			<TextBlock x:Name="QueueSavedTextBlock" Visibility="Collapsed" FontSize="13">Queue was saved to playlist:</TextBlock>
			<TextBlock x:Name="QueueSavedModifiedTextBlock" Visibility="Visible" FontSize="13" Foreground="Red">Queue changed since it was last saved to playlist:</TextBlock>
		</Grid>

        <TextBlock x:Name="CurrentPlaylistNameTextBlock" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="13" Margin="12,125,0,0" Width="380" FontWeight="Bold" Text="(Playlist Name)" />

		<c:TouchButton x:Name="ShuffleButton" Text="Shuffle: Play in random order" ItemAction="ToggleBooleanValue" Width="120" HorizontalAlignment="Left" Margin="13,170,0,0" d:LayoutOverrides="Width, Height" VerticalAlignment="Top" />
		<c:TouchButton x:Name="RepeatButton" Text="Repeat: Start over when done" ItemAction="ToggleBooleanValue" Width="120" HorizontalAlignment="Left" Margin="132,170,0,0" d:LayoutOverrides="Width, Height" VerticalAlignment="Top" />
		
		<c:TouchButton x:Name="GoToAlbumModeButton" Text="Go To Album of Track..." Width="120" HorizontalAlignment="Left" Margin="12,255,0,225" d:LayoutOverrides="Width" Click="GoToAlbumModeButton_Click" />
		<c:TouchButton x:Name="ReorderTracksModeButton" Text="Reorder Tracks in Queue..." Width="120" HorizontalAlignment="Left" Margin="132,255,0,225" d:LayoutOverrides="Width" Click="ReorderTracksModeButton_Click" />
		<c:TouchButton x:Name="DeleteTracksModeButton" Text="Delete Tracks from Queue..." Width="120" HorizontalAlignment="Left" Margin="252,255,0,225" d:LayoutOverrides="Width" Click="DeleteTracksModeButton_Click" />

		<c:Shadow x:Name="GoToAlbumGroup" Margin="12,315,0,0" Opacity="0" Visibility="Collapsed" ShadowOverhang="8" ShadowDarkness="3" HorizontalAlignment="Left" VerticalAlignment="Top">
			<Border Background="#FFFFFF80" BorderBrush="Gray" BorderThickness="1">
				<Grid Margin="8">
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto" />
						<RowDefinition Height="Auto" />
					</Grid.RowDefinitions>
					<TextBlock FontSize="13" Margin="0,0,0,8" LineHeight="16" LineStackingStrategy="BlockLineHeight">Select a track to see the album containing that track.</TextBlock>
					<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center">
						<c:TouchButton x:Name="GoToAlbumCancelButton" Text="Cancel" Width="80" Margin="0,0,8,0" Click="GoToAlbumCancelButton_Click" />
					</StackPanel>
				</Grid>
			</Border>
		</c:Shadow>

		<c:Shadow x:Name="ReorderTracksGroup" Margin="12,315,0,0" Opacity="0" Visibility="Collapsed" ShadowOverhang="8" ShadowDarkness="3" HorizontalAlignment="Left" VerticalAlignment="Top">
			<Border Background="#FFFFFF80" BorderBrush="Gray" BorderThickness="1">
				<Grid Margin="8">
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto" />
						<RowDefinition Height="Auto" />
					</Grid.RowDefinitions>
					<TextBlock FontSize="13" Margin="0,0,0,8" LineHeight="16" LineStackingStrategy="BlockLineHeight">Select tracks in the order you want them to play.<LineBreak/>Press <Run FontWeight="Bold">OK</Run> when you're done.</TextBlock>
					<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center">
						<c:TouchButton x:Name="ReorderTracksUndoButton" Text="Undo One Track" Width="80" Margin="0,0,8,0" Click="ReorderTracksUndoButton_Click" />
						<c:TouchButton x:Name="ReorderTracksOkButton" Text="OK" Width="80" Margin="0,0,8,0" Click="ReorderTracksOkButton_Click" />
						<c:TouchButton x:Name="ReorderTracksCancelButton" Text="Cancel" Width="80" Margin="0,0,8,0" Click="ReorderTracksCancelButton_Click" />
					</StackPanel>
				</Grid>
			</Border>
		</c:Shadow>

		<c:Shadow x:Name="DeleteTracksGroup" Margin="12,315,0,0" Opacity="0" Visibility="Collapsed" ShadowOverhang="8" ShadowDarkness="3" HorizontalAlignment="Left" VerticalAlignment="Top">
			<Border Background="#FFFFA0A0" BorderBrush="Gray" BorderThickness="1">
				<Grid Margin="8">
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto" />
						<RowDefinition Height="Auto" />
					</Grid.RowDefinitions>
					<TextBlock FontSize="13" Margin="0,0,0,8" LineHeight="16" LineStackingStrategy="BlockLineHeight">Select tracks, then press <Run FontWeight="Bold">Delete</Run> to delete them<LineBreak/>from the queue.  They will remain in the library.</TextBlock>
					<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center">
						<c:TouchButton x:Name="DeleteTracksSelectAllButton" Text="Select&#10;All Tracks" Width="80" Margin="0,0,8,0" Click="DeleteTracksSelectAllButton_Click" />
						<c:TouchButton x:Name="DeleteTracksOkButton" Text="Delete" Width="80" Margin="0,0,8,0" Click="DeleteTracksOkButton_Click" />
						<c:TouchButton x:Name="DeleteTracksCancelButton" Text="Cancel" Width="80" Margin="0,0,8,0" Click="DeleteTracksCancelButton_Click" />
					</StackPanel>
				</Grid>
			</Border>
		</c:Shadow>
        
		<c:TouchButton x:Name="GoToCurrentAlbum" Text="Go to&#10;Current Album" Width="120" HorizontalAlignment="Left" Margin="13,0,0,8" VerticalAlignment="Bottom" d:LayoutOverrides="Width, Height" Click="GoToCurrentAlbum_Click" />
		
    </Grid>

</UserControl>

